package com.hundsun.yr.universal.p2p.ui.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.p2p.bean.ListOfCashBean;

import java.util.List;

/**
 *
 * Created by Administrator on 2018/4/28.
 *
 */

public class CashAdapter extends BaseAdapter {
    private Context context;
    private List<ListOfCashBean.ListBean> dataBeans;
    public CashAdapter(Context context, List<ListOfCashBean.ListBean> dataBeans){
        this.context =context;
        this.dataBeans =dataBeans;
    }

    @Override
    public int getCount() {
        return dataBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return dataBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("ViewHolder")
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.cash_item_layout,parent,false);
        TextView textView =view.findViewById(R.id.cash_tv) ;
        String loan = dataBeans.get(position).getWithdraw();
        if (!loan.equals("")&&Double.valueOf(loan)<=0){
            view.setVisibility(View.GONE);
            textView.setVisibility(View.GONE);
            return view;
        }else {
            view.setVisibility(View.VISIBLE);
            textView.setVisibility(View.VISIBLE);
        }
        textView.setText(dataBeans.get(position).getName()+"("+dataBeans.get(position).getWithdraw()+"元)");
       return view;
    }

}
